home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig04_05.jar
/
Ch04
/
Fig04_05
/
Fig04_05.cpp
Wrap
C/C++ Source or Header
|
1997-10-13
|
497b
|
23 lines
// Fig. 4.5: fig04_05.cpp
// Initialize array s to the even integers from 2 to 20.
#include <iostream.h>
#include <iomanip.h>
int main()
{
const int arraySize = 10;
int j, s[ arraySize ];
for ( j = 0; j < arraySize; j++ ) // set the values
s[ j ] = 2 + 2 * j;
cout << "Element" << setw( 13 ) << "Value" << endl;
for ( j = 0; j < arraySize; j++ ) // print the values
cout << setw( 7 ) << j << setw( 13 ) << s[ j ] << endl;
return 0;
}